package cn.edu.gzgs.mapper;

import cn.edu.gzgs.entity.EmailMsg;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Update;

import java.util.List;

/**
 * 邮件消息Mapper
 */
@Mapper
public interface EmailMsgMapper extends BaseMapper<EmailMsg> {

    /**
     * 批量更新邮件为已读状态
     */
    @Update("<script>" +
            "UPDATE email_msg SET is_read = 1 WHERE id IN " +
            "<foreach collection='ids' item='id' open='(' separator=',' close=')'>" +
            "#{id}" +
            "</foreach>" +
            " AND accept_id = #{userId}" +
            "</script>")
    int batchUpdateReadStatus(@Param("ids") List<Long> ids, @Param("userId") String userId);
}